/**
 * style样式的格式化
 * @param {array} data 需要格式化的样式集合
 * */
const useStyleTranslateFormat = function(data: string[] | string[][] | Record<string, any>): string
{
    // 当前的样式格式化值
    const styleTranslate: string[] = [];

    if (isArray(data) && !isEmpty(data))
    {
        data.forEach((item: string | string[]) =>
        {
            if (isString(item) && item)
            {
                styleTranslate.push(item);
            }
            else if (isArray(item) && !isEmpty(item))
            {
                item.forEach((thisItem: string) =>
                {
                    if (thisItem)
                    {
                        styleTranslate.push(thisItem);
                    }
                });
            }
            else if (isObject(item) && !isEmpty(item))
            {
                for (const key in item)
                {
                    if (Object.hasOwn(item, key))
                    {
                        // 当前的值
                        const value = item[key] as string;

                        styleTranslate.push(`${key}:${value}`);
                    }
                }
            }
        });
    }
    else if (isObject(data) && !isEmpty(data))
    {
        data = data as Record<string, any>;

        for (const key in data)
        {
            if (Object.hasOwn(data, key))
            {
                // 当前的值
                const value = data[key] as string;

                styleTranslate.push(`${key}:${value}`);
            }
        }
    }

    return styleTranslate.join(";");
};

export default useStyleTranslateFormat;